# $Id: PKGBUILD 183048 2013-04-17 02:02:03Z allan $
# Maintainer: Allan McRae <allan@archlinux.org>
# Contributor: Andreas Radke <andyrtr@archlinux.org>

pkgname=m4
pkgver=1.4.16
pkgrel=3
pkgdesc="The GNU macro processor"
arch=('i686' 'x86_64')
url="http://www.gnu.org/software/m4"
license=('GPL3')
groups=('base-devel')
depends=('glibc' 'bash')
install=m4.install
source=(ftp://ftp.gnu.org/gnu/m4/$pkgname-$pkgver.tar.xz{,.sig}
        m4-1.4.16-readlink-einval.patch)
md5sums=('7548ec061a1ba993790159764f522d0e'
         'SKIP'
         'cea138fa9b568d06e46269611cec8dd0')

prepare() {
  cd ${srcdir}/$pkgname-$pkgver
  
  # glibc-2.16 compatibility
  sed -i -e '/gets is a/d' lib/stdio.in.h
  
  # patch testsuite failure with newer kernels
  patch -Np1 -i $srcdir/m4-1.4.16-readlink-einval.patch
}

build() {
  cd ${srcdir}/$pkgname-$pkgver  
  ./configure --prefix=/usr
  make
}

check() {
  cd ${srcdir}/$pkgname-$pkgver
  make check
}

package() {
  cd ${srcdir}/$pkgname-$pkgver
  make prefix=${pkgdir}/usr install
}
